package com.paradox.rpc.protocol.Netty;

import com.paradox.rpc.Future;
import com.paradox.rpc.Response;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import java.util.Map;

public class NettyClientHandler extends ChannelInboundHandlerAdapter {

    private Object res;

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        Response response= (Response) msg;
        for(Map.Entry<String,Future> entry:Future.responseReceiver.entrySet()){
            if(entry.getKey().equals(response.getId())){
                Future.responseReceiver.get(entry.getKey()).receive(response.getRes());
            }
        }
        System.out.println(msg);
    }
}
